/**
 * 全局js对象
 */
var Container={};

/**
 * 
 * 进度条部分
 */
//淡入遮罩 --------进度条
Container.showZProgress=function() {
	this.setZProgressSpan(0);
	setTimeout(function() {
		$('#Z_Progress').fadeIn(500);
	}, 50);
};
//设置百分比 进度条
Container.setZProgressSpan=function(val) {
	val = val * 1;
	if (val >= 100) {
		$('#Z_Progress_Span').html(100);
		return;
	}
	var thisVal = $.trim($('#Z_Progress_Span').html()) * 1;
	if (val > thisVal) {
		$('#Z_Progress_Span').html(val);
	}
};
//淡出遮罩 -------- 进度条
Container.closeZProgress=function() {
	setTimeout(function() {
		$('#Z_Progress').fadeOut(500);
	}, 1500);
};
/**
 * 加载数据遮罩部分
 */


//淡入遮罩 -----------加载数据遮罩
Container.showZLoading=function() {
	setTimeout(function() {
		$('#Z_Loading').fadeIn(500);
	}, 50);
};
//淡出遮罩 -----------加载数据遮罩
Container.closeZLoading=function() {
	setTimeout(function() {
		$('#Z_Loading').fadeOut(500);
	}, 50);
};


/**
 * iframe 高度部分
 */



//计算页面的实际高度，iframe自适应会用到
Container.calcPageHeight=function(doc) {
	var cHeight = Math.max(doc.body.clientHeight,doc.documentElement.clientHeight);
	var sHeight = Math.max(doc.body.scrollHeight,doc.documentElement.scrollHeight);
	var height = Math.max(cHeight, sHeight);
	return height;
};
//iframe 加载宽高
Container.iframeLoad=function(elem) {
	var zDoc = elem.contentDocument || elem.document;
	var height = this.calcPageHeight(zDoc);
	height= height+20;
	elem.style.height = height + 'px';
};
$(function(){
	$('.Z_iframe').on('load', function() {
		Container.iframeLoad(this);
	});
});

/**
 * 下拉多选
 */
$(function(){
    Container.initChosenSelect();
});
Container.initChosenSelect=function(){
    var config = {
        ".chosen-select" : {},
        ".chosen-select-deselect" : {
            allow_single_deselect : !0
        },
        ".chosen-select-no-single" : {
            disable_search_threshold : 10
        },
        ".chosen-select-no-results" : {
            no_results_text : "Oops, nothing found!"
        },
        ".chosen-select-width" : {
            width : "95%"
        }
    };
    for ( var selector in config) {
        $(selector).chosen(config[selector]);
    };
};

/**
 * 切换选项卡 重新加载iframe
 */

$(function(){
	//切换选项卡 
	$(document.body).on("click", "a[data-toggle]", function(event) {
		var $href = $(this).attr('href');
		var iframeId = $href.substring(1, $href.length) + 'iframe';
		iframe = document.getElementById(iframeId);
		if (iframe) {
			iframe.src = Container.getUrl(iframe.dataset.src);
		}
	});
});


/**
 * 获取url  避免缓存
 */
Container.getUrl=function(arg) {
	if (arg.indexOf("?") == -1) {
		arg = arg + "?jstime=" + new Date().getTime();
	} else {
		arg = arg + "&jstime=" + new Date().getTime();
	}
	return arg;
};

/**
 * 显示高级搜索
 */
Container.showHigh=function(){
	$('.normalSearch').hide();
 	$('.highSearch').show();
    $('#change').removeClass('col-md-4 col-sm-4  col-xs-4 tl');
    $('#change').addClass('col-md-12 col-sm-12 col-xs-12 tc');
};
/**
 * 清空高级搜索参数
 */
Container.clearHighParam=function(){
	//input
	$.each($('.highSearch input'),function(index,item){
		$(item).val('');
	});
	//select
    $.each($('.highSearch select'),function(index,item){
        $(item).val('');
    });
};
/**
 * 显示普通搜索
 */
Container.showNormal=function(){
    $('.highSearch').hide();
    $('.normalSearch').show();
    $('#change').removeClass('col-sm-12 col-md-12 col-xs-12 tc');
    $('#change').addClass('col-sm-4 col-md-4 col-xs-4 tl');
    //清空高级搜索参数
    Container.clearHighParam();
};
/**
 * 设置右侧 侧边栏 地址
 */
Container.setIframeSrc=function (url) {
	$('#rightContent iframe').get(0).src=this.getUrl(url);
};
/**
 * 显示右边栏
 */
Container.showRight=function () {
    $('#leftContent').attr('class','col-md-8 col-sm-8 col-xs-8 pl0');
    $('#rightContent').attr('class','col-md-4 col-sm-4 col-xs-4 pr0');
    document.getElementById('rightContent').style.display='block';
};

/**
 * 隐藏右边栏
 */
Container.hideRight=function () {
    document.getElementById('rightContent').style.display='none';
    $('#leftContent').attr('class','col-md-12 col-sm-12 col-xs-12');
    this.setIframeSrc('');
};

/**
 * 去定位锚点
 */
Container.myHash=function (hashId) {
    window.location.hash='';
    window.location.hash ='#'+hashId;
};
